Conversation
3 tasks
arcanis
added a commit
that referenced
this pull request
Nov 7, 2025
## What's the problem this PR addresses? Fixes #6890 Fixes #6145 Node's [implementation](https://github.com/nodejs/node/blob/94cbb7758282bf5db837412f7cb3698f17ac1af3/lib/internal/fs/promises.js#L648) of `FileHandle#read` allows reading into `TypedArray`s and `DataView`s (collectively known as `ArrayBufferView`s, and checks for them using `ArrayBuffer.isView()`. On the other hand, our implementation checks using `Buffer.isBuffer()` and thus only allows `Buffer`. If an `ArrayBufferView` is given, it treats them as an options bag and pass its `.buffer` (which is an `ArrayBuffer`) as the sink to the backing fs. If the backing fs is Node's native `fs` then it would throw. ## How did you fix it? Allow `ArrayBufferView`s by checking with `ArrayBuffer.isView()` as in Node's implementation. Because the underlying `FakeFS` interface only allows `Buffer` (and changing that would be a breaking change), a `Buffer` backed by the `ArrayBufferView` is used. (Q: Should we make that change next major?) Also un-vendored the TypeScript types if the exact same type is available from `@types/node` along the way. AFAICT those were vendored because those types wasn't available at first? \cc @merceyz This fix should be orthogonal to #6919 ## Checklist <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [x] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [x] I will check that all automated PR checks pass before the PR gets reviewed. --------- Co-authored-by: Maël Nison <nison.mael@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's the problem this PR addresses?
The current implementation of file handles on Node.js was a little heavy-handed, as we were going through our own
FileHandleclass, bypassing the Node.js one. Should our implementation be behind (which is the case), userland would also rely on the outdated implementation rather than the stock Node.js one.Fixes #6890
How did you fix it?
We now only use our own
FileHandleimplementation for files located within zip archives.Checklist